﻿using UnityEngine;
using System.Collections;

public class logic_cards: MonoBehaviour {
	private MemoryCards [] Cards = new MemoryCards[2];
	private int TongChon = 0;
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}

	public void selectCardsLogic(MemoryCards mc)
	{

		if (Cards [0] == null) {
						Cards [0] = mc;
			//Debug.Log(mc.cardnumber);
				} else {
			Cards[1]=mc;
			//Debug.Log(mc.cardnumber);

			TongChon++;
			if(Cards[0].cardnumber==Cards[1].cardnumber)
			{
				TrueSelect();
			}else{
				SelectNoTrue();
			}
		}
	}
	void TrueSelect()
	{
		Cards [0].deleteCard ();
		Cards [1].deleteCard ();

	}
	void SelectNoTrue()
	{
		Cards[0].SelectNotrue();
		Cards[1].SelectNotrue();
		Debug.Log(Cards[0]+"----"+Cards[1]);
		Cards[0]=null;
		Cards[1]=null;
		
		Debug.Log(Cards[0]+"----"+Cards[1]);
	}
}
